package com.rcl.mvvmdemo.musicList

import com.rcl.mvvmdemo.player.domain.Music

class MusicsModel {
    val result: ArrayList<Music> = arrayListOf<Music>()

    fun loadMusicByPage(page: Int, size: Int, callback: onMusicLoadResult) {
        Thread {
            Thread.sleep(2000)
            for (i in (0 until size)) {
                result.add(
                    Music(
                        "音乐名称 $i",
                        "音乐封面 $i",
                        "url==> $i"
                    )
                )
            }

            //数据请求完成
            //通知数据更新
            callback.onSuccess(result)
        }.start()
    }

    interface onMusicLoadResult {
        fun onSuccess(result: List<Music>)
        fun onError(msg: String, code: Int)
    }
}